﻿
namespace TestProject
{
    using System;
    using Swiss;

    /*
     * This class contains the application specific properties of a measurement.
     * It is added to the Data Class as the Payload of it'Result Measurement Item.
     * 
     * Note: Every property should set the Dirty Flag if changed by using CompareAndSetDirty().
     * Note: This file needs a Measurement.settings file containing the default values of the properties.
     * Note: Enum Flags can be entered by separating them by comma'Result
     * Note: All loading is typesafe and is lcoated in the applications namespace.
     */

    namespace TestWrapper_Data
    {
        #region Measurement;

        /// <summary>
        /// This class is the actual (external) payload of the Serie Collection SerieItem themselves. 
        /// Bookkeeping properties like Index are part of the Collection SerieItem itself.
        /// </summary>
        public class Measurement : IDirty
        {

            public const int maxpnt = 999;
            public const int nosamp = maxpnt + 1;

            #region IDirty Members

            public event OnChange DoChange;

            object IDirty.CompareAndSetDirty(object prop, object value)
            {
                if (!prop.Equals(value))
                {
                    if (DoChange != null)
                    {
                        DoChange();
                    }
                }

                return value;
            }

            #endregion IDirty Members

            private Object CompareAndSetDirty(Object prop, Object value)
            {
                return ((IDirty)this).CompareAndSetDirty(prop, value);
            }

            #region Properties

            //Visible when reflecting
            private Int32 fValue = 120;
            [Swiss.Section("Test")]
            public Int32 Value
            {
                get { return fValue; }
                set { fValue = (Int32)CompareAndSetDirty(fValue, value); }
            }

            #endregion Properties

            public Measurement()
            {
                //Nothing
            }
        }

        #endregion Measurement;
    }

}
